var aboutApp = angular.module('aboutApp', []);
var mysf=function(){
	this.list=[
	{id:126323,name:'德克士',score:120,grade:'热门快餐'},
	{id:123232,name:'华莱士',score:5100,grade:'热门快餐'},
	{id:122343,name:'乡村基',score:545,grade:'热门快餐'},
	{id:232224,name:'蜜雪冰城',score:520,grade:'冷饮系列'},
	{id:124325,name:'华莱士',score:95,grade:'最多点击'},
	{id:123246,name:'小龙坎',score:335,grade:'最多点击'},
	{id:133257,name:'肯德基',score:169,grade:'最多点击'},
	{id:122358,name:'钢铁侠',score:158,grade:'热门电影'},
	{id:123259,name:'益禾堂',score:330,grade:'冷饮系列'},
	{id:122360,name:'蜘蛛侠',score:59,grade:'热门电影'},
	{id:192332,name:'肖申克的救赎',score:86,grade:'热门电影'},
	{id:182212,name:'小龙虾',score:335,grade:'热门小吃'},
	{id:173413,name:'古茗',score:360,grade:'冷饮系列'},
	{id:162314,name:'螺蛳粉',score:196,grade:'热门小吃'}
	]
	//根据参数显示莫给系列的详情
	this.getList=function(grade2){
		console.log(grade2)
		var  stu=[];
		this.list.forEach(function(item){
			if(item.grade==grade2){
				stu.push(item)
			}
		})
		return stu;
	}
	//根据id删除数据
	this.del=function(id){
		alert('您确定删除订单'+id)
		var ss=this.list;
		this.list.forEach(function(item,index){
			console.log(item.id==id)
			if(item.id==id){
				ss.splice(index,1)
			}
		})
		return ss;
	}
	//添加方法
	this.add=function(id,name,grade,score){
		var user={
			id:id,
			name:name,
			grade:grade,
			score:score
		}
		this.list.unshift(user)
		return this.list
	}
}
aboutApp.service("myss",mysf)
aboutApp.controller("aboutCon",function($scope,myss){
	//查询所有系列
	$scope.all=myss.list;
	//系列查询
	$scope.list3=myss.getList("冷饮系列")
	$scope.list4=myss.getList('热门电影')
	$scope.list8=myss.getList("热门小吃")
	$scope.list11=myss.getList("最多点击")
	$scope.list12=myss.getList("热门快餐")
	
	$scope.list1=myss.getList($scope.grade2)
	console.log($scope.list1)
	//删除
	$scope.del=function(id){
		myss.del(id)
	};
	//添加
	$scope.add=function(id,name,grade,score){
		myss.add(id,name,grade,score)
	}
	//小众系列<60的价格
	$scope.scoreno=function(arr){
		return arr.score<60
	}
	$scope.flag=true
})
